package com.ijunfu.proxy._01_jdk;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 *
 * @title  : 
 * @author : ijunfu <ijunfu@163.com>
 * @date   : 2023/10/29 15:31
 * @version: 1.0
 * @motto  : 位来可期 - 世界很大，我想看看
 *
 */
@Slf4j
public class ServiceProxy implements InvocationHandler {

    private Object targetObject;

    public ServiceProxy(Object targetObject) {
        this.targetObject = targetObject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        log.info("S: 调用目标方法之前");
        Object invoke = method.invoke(targetObject, args);
        log.info("E: 调用目标方法之后");
        return invoke;
    }
}
